import time

def log(f):
    def metric(*args, **kw):
        start_time = time.time()
        f(*args, **kw)
        end_time = time.time()
        print('{},该函数执行耗时: {:.4f}s'.format(f.__name__, end_time - start_time))
        return
    return metric

@log
def add(x):
    i = 1
    sum = 0
    while(i <= x):
        sum += x
        i += 1
    print("sum = ", sum)

add(10000)

